<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>
    <style>
        .btn, .input-group .input-group-btn .btn{border-width: 1px;}
    </style>
    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="page-content">
                        <div class="page-content-area">
                            <div class="row">
                                <div class="col-xs-12">
                                    <!-- PAGE CONTENT BEGINS -->

                                    <!--/span-->
                                    <!-- left menu ends -->



                                    <div class="actions-bar" style="margin-bottom: 10px;overflow: hidden;">
                                        <form class="form-inline search-form">
                                            <div class="pull-right">
                                            <!-- <div class=""> -->
                                                <div class="input-group">
                                                    <input type="text" name="q" value="" placeholder="小说或派单渠道名称" style="width: 100%;">
                                                    <span class="input-group-btn">
                                                        <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button>
                                                    </span>
                                                </div>                                                
                                            </div>
                                        </form>

                                    </div>

                                    <table class="table table-striped table-bordered table-hover responsive">
                                        <thead>
                                            <tr>
                                                <td>
                                                    推广链接
                                                </td>
                                                <td>
                                                    入口页面
                                                </td>
                                                <td class="text-right">
                                                    点击
                                                </td>
                                                <td class="text-right">
                                                    新增用户
                                                </td>
                                                <td class="text-right">
                                                    新增关注
                                                </td>
                                                <td class="text-right">
                                                    充值金额
                                                </td>
                                                <td class="text-center">
                                                    操作
                                                </td>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <volist name="list" id="vo">
                                            <tr class="referral-link-item">
                                                <td>
                                                    <div style="margin-bottom:5px;">
                                                        <span class="link-desc">{$vo.description}</span> 
                                                    </div>
                                                    <span class="text-primary" id="link_{$vo.id}">http://{$domain}/p/{$vo.id}</span>
                                                    <!-- <i class="fa fa-copy" title="点击复制" style="cursor:pointer;" data-toggle="copy-link" data-clipboard-target="#link-498789"></i> -->
                                                    <i class="user_copy_link" title="点击复制" style="cursor:pointer;display: inline-block; padding: 5px; background-color: #438eb9; color: #fff; font-style: normal; border-radius: 3px;font-size: 12px;" data-clipboard-action="copy" data-clipboard-target="#link_{$vo.id}">点击复制</i>
                                                    <div class="text-muted" style="font-size:13px;margin-top:5px">
                                                        创建时间: {$vo.created|date='Y-m-d H:i:s' , ###}                
                                                    </div>
                                                </td>
                                                <td class="index-page" data-bookid="{$vo.bookid}" data-chapterid="{$vo.chapterid}">
                                                    <div style="line-height:1.7em">
                                                        <a href="{:U('Novel/view' , ['bookid' => $vo['bookid']])}">{$vo.book_title}</a>
                                                        <br>
                                                        {$vo.chapter_name}                
                                                    </div>                                                    
                                                </td>
                                                <td class="text-right">
                                                    <span class="counter-field" data-field="clicks">{$vo.hits}</span>
                                                </td>
                                                <td class="text-right">
                                                    <span class="counter-field" data-field="member_count">{$vo.newuser}</span>
                                                </td>
                                                <td class="text-right">
                                                    <span class="counter-field" data-field="subscribe_count">{$vo.newsubs}</span>
                                                    <div class="text-muted subscribe-rate-container" style="font-size:12px;margin-top:5px;">
                                                        关注率 <span class="counter-field" data-field="subscribe_rate">0</span>%
                                                    </div>
                                                </td>
                                                <td class="text-right">{$vo.amount}</td>
                                                <td class="text-center">
                                                    <a href="{:U('Order/index' , ['status' => 1, 'referlink' => $vo['id']])}" class="btn btn-xs btn-success"><i class="fa fa-list"></i> 订单明细</a>
                                                    
                                                </td>
                                            </tr>
                                            </volist>
                                        </tbody>
                                    </table>

                                    <div>{$page}</div>
                                    <!-- PAGE CONTENT ENDS -->
                                </div><!-- /.col -->
                            </div><!-- /.row -->
                        </div><!-- /.page-content-area -->
                    </div>
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>
</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<script type="text/javascript" src="__PUBLIC__/static/js/admin.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/clipboard.min.js"></script>
<script type="text/javascript">
    $(".chapter-title").on("click", function () {
        var id = $(this).attr("data-id");
        $.get("{:U('content')}", {id: id}, function (data) {
            if (data != 0) {
                $("#modal-chapter-title").text(data.chapter_name);
                $("#modal-chapter-content").html(data.content);
                $("#myModal").modal('show');
            }
        });
    });
    $(".ref-link").on("click", function () {
        $("#link-title").html("生成推广链接");
        $("#create-referral-link-modal").modal('show');
        $("#small-chapter-name").text($(this).attr("data-title"));
        $("#small-book-thumb").attr("src", $("#book-thumb").attr("src"));
        $("input[name=bookid]").val($(this).attr("data-book"));
        $("input[name=chapterid]").val($(this).attr("data-chapter"));

    });

    $("#btn-make").on("click", function () {
        var description = $("input[name=description]").val();
        var bookid = $("input[name=bookid]").val();
        var chapterid = $("input[name=chapterid]").val();
        if (description.trim() == '') {
            layer.alert("请输入派单渠道名称");
            return false;
        }

        $.post("{:U('Referlink/create')}", {description: description, bookid: bookid, chapterid: chapterid}, function (data) {
            if (data.status == 1) {
                window.location.href = "{:U('Referlink/index')}"
            }
            layer.alert(data.msg);
        })
    });

    $(".index-page").each(function(index,element){ 
        var bookid = $(this).attr("data-bookid");
        var chapterid = $(this).attr("data-chapterid");
        $.get("{:U('Novel/')}")
    });
    /*点击复制*/
    var clipboard = new Clipboard('.user_copy_link');
    clipboard.on('success', function(e) {
        e.clearSelection();
    });

    clipboard.on('error', function(e) {
        console.log('复制失败,请手动选择复制');
    });
    $(".user_copy_link").on("click" , function(){
        var a = $(this).prev($(".text-primary")).text();
        document.execCommand("Copy");
        layer.open({
                type: 0, 
                title:'友情提示：',
                content: '链接已经复制到粘贴板',
                time:2000,

            });
    });

</script>
</body>
</html>